/*
 * 作者: 侯晓宇
 * 时间: 2017-01-11 
 * 说明：
 * Copyright (c) 2016-2017 中研沃兮
 */
define(function(require) {
	require("jquery");

	var c = require('app/utils/CommonUtils');
	var hc = require('app/utils/HttpClientUtils');
	var tip = require('app/utils/TipUtils');
	var win = window;

	var action = {};

	action.openSearch = function() {
		var UISearchBar = api.require('UISearchBar');
		UISearchBar.open({
			placeholder: '请输入搜索关键字',
			historyCount: 10,
			showRecordBtn: false,
			texts: {
				cancelText: '取消',
				clearText: '清除搜索记录'
			},
			styles: {
				navBar: {
					bgColor: '#FFFFFF',
					borderColor: '#ccc'
				},
				searchBox: {
					bgImg: '',
					color: '#000',
					height: 44
				},
				cancel: {
					bg: 'rgba(0,0,0,0)',
					color: '#D2691E',
					size: 16
				},
				list: {
					color: '#696969',
					bgColor: '#FFFFFF',
					borderColor: '#eee',
					size: 16
				},
				clear: {
					color: '#000000',
					borderColor: '#ccc',
					size: 16
				}
			}
		}, function(ret, err) {
			if(ret.eventType == "history" || ret.eventType == "search"){
				var text = ret.text;
				
				if(c.isNullStr(text.trim())){
					tip.show("请输入搜索关键字");
					return;
				}
				api.openWin({
	                name: 'SearchResultWin',
	                url: './SearchResultWin.html',
	                pageParam:{
	                	keyword: text
	                }
                });
			}
		});
	};
	
	
	
	
	action.openAdminUserSearch = function() {
		var UISearchBar = api.require('UISearchBar');
		UISearchBar.open({
			placeholder: '请输入用户手机号搜索',
			historyCount: 10,
			showRecordBtn: false,
			texts: {
				cancelText: '取消',
				clearText: '清除搜索记录'
			},
			styles: {
				navBar: {
					bgColor: '#FFFFFF',
					borderColor: '#ccc'
				},
				searchBox: {
					bgImg: '',
					color: '#000',
					height: 44
				},
				cancel: {
					bg: 'rgba(0,0,0,0)',
					color: '#D2691E',
					size: 16
				},
				list: {
					color: '#696969',
					bgColor: '#FFFFFF',
					borderColor: '#eee',
					size: 16
				},
				clear: {
					color: '#000000',
					borderColor: '#ccc',
					size: 16
				}
			}
		}, function(ret, err) {
			if(ret.eventType == "history" || ret.eventType == "search"){
				var text = ret.text;
				
				if(c.isNullStr(text.trim())){
					tip.show("请输入用户手机号搜索");
					return;
				}
				api.openWin({
	                name: 'AdminUserSearchResultWin',
	                url: './AdminUserSearchResultWin.html',
	                pageParam:{
	                	keyword: text
	                }
                });
			}
		});
	};

	action.openEnrollRelationSearch = function() {
		var UISearchBar = api.require('UISearchBar');
		UISearchBar.open({
			placeholder: '请输入关键字搜索',
			historyCount: 10,
			showRecordBtn: false,
			texts: {
				cancelText: '取消',
				clearText: '清除搜索记录'
			},
			styles: {
				navBar: {
					bgColor: '#FFFFFF',
					borderColor: '#ccc'
				},
				searchBox: {
					bgImg: '',
					color: '#000',
					height: 44
				},
				cancel: {
					bg: 'rgba(0,0,0,0)',
					color: '#D2691E',
					size: 16
				},
				list: {
					color: '#696969',
					bgColor: '#FFFFFF',
					borderColor: '#eee',
					size: 16
				},
				clear: {
					color: '#000000',
					borderColor: '#ccc',
					size: 16
				}
			}
		}, function(ret, err) {
			if(ret.eventType == "history" || ret.eventType == "search"){
				var text = ret.text;
				var p= api.pageParam;
				p.searchtype="enrollrelation";
				p.keyword=text;
				if(c.isNullStr(text.trim())){
					tip.show("请输入关键字搜索");
					return;
				}
				api.openWin({
	                name: 'SearchResultWin',
	                url: './SearchResultWin.html',
	                pageParam:p
                });
			}
		});
	};
	return action;
});